import React, { Component } from 'react'


export default class App extends Component {

    state = {
        title: '',
        todoList: []
    }

    render() {
        return (
            <div>
                <input type="text" value={this.state.title} onChange={(event) => {
                    // console.log(event.target.value);
                    this.setState({
                        title: event.target.value
                    })
                }} />
                <button onClick={() => {
                    console.log(this.state.title);
                    this.setState({
                        todoList: [this.state.title, ...this.state.todoList]
                    })
                }}>提交</button>

                <ol>
                    {this.state.todoList.map((item, index) => {
                        return <li key={index}> {item} </li>
                    })}
                </ol>
            </div>
        )
    }
}
